home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / ka9q / kit_src / mk_start.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-03  |  2.7 KB  |  90 lines

  1. /*    (C) Copyright 1991 Dave Fritsche (wb8zxu), All Rights Reserved.
  2.  * 
  3.  *    Redistribution and use in source and binary forms are permitted for
  4.  *    non-commercial use, provided that the above copyright notice and this
  5.  *    paragraph are duplicated in all such forms.  THIS SOFTWARE IS PROVIDED
  6.  *    ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  7.  *    WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
  8.  *    FITNESS FOR A PARTICULAR PURPOSE.
  9.  */
  10. #include <stdio.h>
  11. #include <dir.h>
  12. #include "screen.h"
  13.  
  14. mk_start(fnm)
  15. unsigned char fnm[];
  16. {
  17.     FILE *start;
  18.     unsigned char buf[128], drive[MAXDRIVE], dir[MAXDIR], fname[MAXFILE];
  19.     unsigned char ext[MAXEXT], tmp_path[128], root_dir[128];
  20.     int n, m, stat;
  21.  
  22.     sprintf(buf, "%s\\bin\\%s", path, fnm);
  23.     if (debug)
  24.     {
  25.         printf("***> startnos.bat file (%s):\n", buf);
  26.         start = stdout;
  27.     }
  28.     else
  29.     {
  30.         if ( (start = fopen(buf, "w")) == NULL )
  31.         {
  32.             printf("\nCan't open \"%s\" for write, aborting!\n\n", buf);
  33.             exit(-1);
  34.         }
  35.     }
  36.  
  37.     fprintf(start, "echo off\n");
  38.     stat = fnsplit(path, drive, dir, fname, ext);
  39.     fprintf(start, "%s\n", drive);
  40.     if ( (stat & DIRECTORY) || (stat & FILENAME) )
  41.         fprintf(start, "cd %s%s\n", dir, fname);
  42.     else
  43.         fprintf(start, "cd \\ \n", dir, fname);
  44.  
  45.     fprintf(start, "set TZ=%s0\n", timezone);
  46.     fprintf(start, "del %s\\spool\\mqueue\\*.lck\n", path);
  47.     fprintf(start, "del %s\\spool\\mail\\*.lck\n", path);
  48.     fprintf(start, "del nos_old.log\n");
  49.     fprintf(start, "ren nos.log nos_old.log\n");
  50.  
  51.     strcpy(tmp_path, path);
  52.     m = strlen(tmp_path);
  53.     for (n = 0; n < m; n++)
  54.         if (tmp_path[n] == '\\')
  55.             tmp_path[n] = '/';
  56.     n = fnsplit(tmp_path, drive, dir, fname, ext);
  57.     strcpy(root_dir, dir);
  58.     strcat(root_dir, fname);
  59.     if (strlen(root_dir) < 1)
  60.         strcpy(root_dir, "/");
  61.  
  62.     if (ka9q && !g1emm)
  63.         fprintf(start, "bin\\noska9q -d %s %s%s/ka9q.net\n",
  64.                 root_dir, dir, fname);
  65.     if (!ka9q && g1emm)
  66.         fprintf(start, "bin\\nosg1emm -d %s %s%s/g1emm.net\n",
  67.                 root_dir, dir, fname);
  68.     if (ka9q && g1emm)
  69.     {
  70.         fprintf(start, "if %c1X==X goto ka9q\n", 37);
  71.         fprintf(start, "if %c1X==ka9qX goto ka9q\n", 37);
  72.         fprintf(start, "if %c1X==KA9QX goto ka9q\n", 37);
  73.         fprintf(start, "if %c1X==g1emmX goto g1emm\n", 37);
  74.         fprintf(start, "if %c1X==G1EMMX goto g1emm\n", 37);
  75.         fprintf(start, "echo Usage:  \%0 [ka9q | g1emm]\n");
  76.         fprintf(start, "goto end\n");
  77.         fprintf(start, ":ka9q\n");
  78.         fprintf(start, "bin\\noska9q -d %s %s%s/ka9q.net\n",
  79.                 root_dir, dir, fname);
  80.         fprintf(start, "goto end\n");
  81.         fprintf(start, ":g1emm\n");
  82.         fprintf(start, "bin\\nosg1emm -d %s %s%s/g1emm.net\n",
  83.                 root_dir, dir, fname);
  84.         fprintf(start, ":end\n");
  85.     }
  86.  
  87.     if (!debug)
  88.         fclose(start);
  89. }
  90.